package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.RoleDto;
import com.zzyl.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface RoleMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Role record);

    int insertSelective(Role record);

    Role selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Role record);

    int updateByPrimaryKey(Role record);

    int batchInsert(@Param("list") List<Role> list);

    Page<Role> selectPage(RoleDto roleDto);

    List<Role> findRoleListByUserId(Long userId);

    @Select("select * from sys_role where data_state = '0' order by create_time desc")
    List<Role> list();

    @Select("select resource_no from sys_role_resource where role_id=#{roleId}")
    List<Long> findCheckedResources(Long roleId);


    @Select("select data_state from sys_role where id in (#{roleIds})")
    List<Long> selectStates(List<Long> roleIds);

    void deleteBatchIds(List<Long> roleIds);
}